<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<head>
</head>
<body>
<article class="page-container" id="mainArt">
	<form id="form1" class="form form-horizontal" action="${ctx}/dict/saveEntity.do" method="post" enctype="multipart/form-data">
		<c:if test="${entity.id != null}"><input type="hidden" id="entityID" name="id" value="${entity.id }" /></c:if>
		<div class="row cl">
			<label class="form-label col-xs-2"><span class="c-red">*</span>类型:</label>
			<div class="formControls col-xs-4">
				<input id="type" name="type" class="input-text required" value="${entity.type }"  type="text"  placeholder="如:sys_user_able" />
			</div>
			<label class="form-label col-xs-2"><span class="c-red">*</span>排序:</label>
			<div class="formControls col-xs-4">
				<input id="sort" name="sort" class="input-text required number"   value="${entity.sort }"  type="text" placeholder="如:10"/>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-2"><span class="c-red">*</span>标签名:</label>
			<div class="formControls col-xs-4">
				<input id="label" name="label" class="input-text required"   value="${entity.label }"  type="text" placeholder="如：是"/>
			</div>
			<label class="form-label col-xs-2"><span class="c-red">*</span>数据值:</label>
			<div class="formControls col-xs-4">
				<input id="value" name="value" class="input-text required"   value="${entity.value }"  type="text" placeholder="如：1"/>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-2"><span class="c-red">*</span>描述:</label>
			<div class="formControls col-xs-10">
				<textarea id="remarks" name="remarks" class="textarea" value="${entity.remarks }" placeholder="功能描述 如：是否冻结"   type="text" >${entity.remarks }</textarea>
			</div>
		</div>

		<div class="row cl">
			<div id="buttonDiv" class="col-xs-6 col-xs-offset-3 text-c">
				<c:if test="${entity.id != null}">
					<a href="javascript:submit();" class="btn btn-success radius"><i class="Hui-iconfont">&#xe60c;</i> 修改</a>
				</c:if>
				<c:if test="${entity.id == null}">
					<a href="javascript:submit();" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加</a>
				</c:if>
			</div>
		</div>
	</form>
</article>
<script type="text/javascript">
	$(function(){
		$("#form1").validate({
			rules:{
			},
			onkeyup:false,
			focusCleanup:true,
			success:"valid",
			submitHandler:function(form){
				var index = layer.load();
				$(form).ajaxSubmit({
	                success:function(data){ //提交成功的回调函数  
	            	  	layer.close(index);  
	                    if(data.flag==200){
	    		        	layer.alert(data.msg,{icon:6},function(index){
	                			if(data.isUpdate == "false"){
	                				parent.location.reload();
	                			}else{
	                				parent.reloadTable();
	                			}
    		                	//关闭当前弹窗
    		    				var index = parent.layer.getFrameIndex(window.name);
    		    				parent.$('.btn-refresh').click();
    		    				parent.layer.close(index);
                				layer.close(index);
                			});
	    	       		} else{
	    	       			layer.alert(data.msg, {icon: 5});
	    	       		}
	                },
	                error:function(data){
	            		layer.close(index);  
	                	layer.alert("操作失败",{icon:5},function(index){
            				//刷新父级
            				parent.location.reload();
		                	//关闭当前弹窗
		    				var index = parent.layer.getFrameIndex(window.name);
		    				parent.$('.btn-refresh').click();
		    				parent.layer.close(index);
            				layer.close(index);
            			});     
	                }
				});
			}
		});
	});
	function submit(){
		$("#form1").submit();
	}
</script>
</body>
</html>